package drds.data_propagate.binlog.event;

import drds.data_propagate.binlog.Buffer;

/**
 * @author jianghang 2013-4-8 上午12:36:29
 * @version 1.0.3
 * @since mysql 5.6
 */
public class RowsQueryEvent extends IgnorableEvent {

    private String rowsQuery;

    public RowsQueryEvent(Header header, Buffer buffer, FormatDescriptionEvent formatDescriptionEvent) {
        super(header, buffer, formatDescriptionEvent);

        final int commonHeaderLen = formatDescriptionEvent.commonHeaderLength;
        final int postHeaderLen = formatDescriptionEvent.eventPostHeaderLength[header.eventType - 1];

        /*
         * m_rows_query length is stored using only one byte, but that length is
         * ignored and the complete query is read.
         */
        int offset = commonHeaderLen + postHeaderLen + 1;
        int len = buffer.limit() - offset;
        rowsQuery = buffer.getFullString(offset, len, Buffer.ISO_8859_1);
    }

    public String getRowsQuery() {
        return rowsQuery;
    }

}
